<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增租户顶部选项卡')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-title-add">
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">标题：</label>
                <div class="col-sm-8">
                    <input name="titleName" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">窗口标题：</label>
                <div class="col-sm-8">
                    <input name="targetTitle" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">背景色：</label>
                <div class="col-sm-8">
                    <input name="colour" class="" type="hidden" required value="#FAF7F7">
                    <div id="chooseBtn"></div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">显示角色：</label>
                <div class="col-sm-8">
                    <p style="color: red">不选默认全部角色都显示</p>
                    <label th:each="role:${roles}" class="check-box">
                        <input name="roleIds" type="checkbox" th:value="${role.roleId}" th:text="${role.roleName}"
                               th:disabled="${role.status == '1'}">
                    </label>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">状态：</label>
                <div class="col-sm-8">
                    <div class="radio-box" th:each="dict : ${@dict.getType('sys_normal_disable')}">
                        <input type="radio" th:id="${'status_' + dict.dictCode}" name="status" th:value="${dict.dictValue}" th:checked="${dict.default}" required>
                        <label th:for="${'status_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">排序：</label>
                <div class="col-sm-8">
                    <input name="sort" class="form-control" type="text" required>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "tenant/title"
        $("#form-title-add").validate({
            focusCleanup: true
        });

        layui.use('colorpicker', function(){
            var $ = layui.$
                ,colorpicker = layui.colorpicker;
            //预定义颜色项
            colorpicker.render({
                elem: '#chooseBtn'
                ,color: '#FAF7F7'
                ,predefine: true // 开启预定义颜色
                ,done: function(color){
                    $('input[name=colour]').val(color);
                }
            });
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-title-add').serialize());
            }
        }
    </script>
</body>
</html>